import {DateUtils} from '../../utils/Utils';

import IMOne2OneCommentLinker from './IMOne2OneCommentLinker';
import PostConstants from '../../common/PostConstants';

import UserRequestNoticeListAction from '../../actions/user/UserRequestNoticeListAction';
import PostRequestMyPostCommentsAction from '../../actions/post/PostRequestMyPostCommentsAction';

//单个聊天的链接
export default class UserNoticeChatLinker extends IMOne2OneCommentLinker {
  constructor(props) {
    super(props);

    this._dataKey = "none";
  }

  init(params) {
    super.init(params);
    if(this._params.noticeData.key === "quanzi_post") {
      this._dataKey = "comment_id";
    }
    else if(this._params.noticeData.key === "news") {

    }
    else if(this._params.noticeData.key === "zahupu_post") {
      this._dataKey = "comment_id";
    }
  }

  _sendAction(page) {
    if(this._params.noticeData.key === "quanzi_post") {
      new PostRequestMyPostCommentsAction().call(this, {board_type:PostConstants.BORDER_TYPE.QUANZI, page:page});
    }
    else if(this._params.noticeData.key === "news") {

    }
    else if(this._params.noticeData.key === "zahupu_post") {
      new PostRequestMyPostCommentsAction().call(this, {board_type:PostConstants.BORDER_TYPE.ZAHUOPU, page:page});
    }
    // new UserRequestNoticeListAction().call(this, {page:page, tag:0})
  }

  _sortData(aData, bData) {
    var timeStr = "";
    if(this._params.noticeData.key === "quanzi_post") {
      timeStr = "commented_at";
    }
    else if(this._params.noticeData.key === "news") {
      timeStr = "posted_at";
    }
    else if(this._params.noticeData.key === "zahupu_post") {
      timeStr = "commented_at";
    }
    let aDate1 = DateUtils.getDate(aData[timeStr]);
    let bDate2 = DateUtils.getDate(bData[timeStr]);
    return DateUtils.compareDate(aDate1, bDate2);
  }
}
